$(document).ready(function() {
	$(".highMe tr").mouseover(function() {
		$(this).addClass("highlight");
	});
	
	$(".highMe tr").mouseout(function() {
		$(this).removeClass("highlight");
	});
});


function editRow(row, url) {
	$('td.val_'+ row).each(function() {
		val_id = this.id.split(',');
		$(this).html('<input class="inline_edit" type="' + val_id[0] + '" name="values[' + val_id[1] + ']" id="' + val_id[1] + '" value="' + $(this).html() + '" />');
	});
	
	$('#editLink_' + row).replaceWith('<a id="editLink_' + row + '" href="javascript:saveRow(' + row + ', \'' + url + '\');"><span class="save_row"></span></a>');
}

function saveRow(row, url) {
	
	$('#editLink_' + row).wrapInner(ajax_load_xs);
	
	var params	= {};
	
	params['uid'] = row;
	
	$('td.val_'+ row).each(function() {
		val_id	= this.id.split(',');
		params[val_id[1]] = $('#' + val_id[1]).val();
		$(this).html($('#' + val_id[1]).val());
	});
	
	$.post(url, params, function(data) {
		$('#editLink_' + row).replaceWith('<a id="editLink_' + row + '" href="javascript:editRow(' + row + ', \'' + url + '\');"><span class="edit_row"></span></a>');
	});
}

function delRow(row, url)
{
	var valid = confirm('Confirm delete');
	
	if(valid)
	{
		$.post(url, { uid: row }, function(data) {
			$("#"+ row).fadeOut("slow");
		});
	}
}